using System.ComponentModel.DataAnnotations;

namespace MonitorPlatform.Data.Entities
{
    public class ApiMetric : BaseEntity
    {
        [Required]
        [StringLength(50)]
        public string AppId { get; set; } = string.Empty;

        [Required]
        [StringLength(100)]
        public string SessionId { get; set; } = string.Empty;

        [StringLength(100)]
        public string? UserId { get; set; }

        public DateTime Timestamp { get; set; }

        [Required]
        [StringLength(500)]
        public string ApiUrl { get; set; } = string.Empty;

        [StringLength(500)]
        public string? ApiPath { get; set; }

        [Required]
        [StringLength(10)]
        public string HttpMethod { get; set; } = string.Empty;

        public int? StatusCode { get; set; }

        // Timing Metrics
        public double ResponseTime { get; set; }
        public double? DnsLookupTime { get; set; }
        public double? TcpConnectTime { get; set; }
        public double? SslHandshakeTime { get; set; }
        public double? TimeToFirstByte { get; set; }
        public double? ContentDownloadTime { get; set; }

        // Request/Response Size
        public long? RequestSize { get; set; }
        public long? ResponseSize { get; set; }
        public long? TransferredSize { get; set; }

        // Request Headers (JSON)
        public string? RequestHeaders { get; set; }

        // Response Headers (JSON)
        public string? ResponseHeaders { get; set; }

        // Error Information
        public bool IsError { get; set; } = false;
        public string? ErrorMessage { get; set; }
        public string? ErrorType { get; set; }

        // Cache Information
        public bool FromCache { get; set; } = false;
        public string? CacheType { get; set; }

        // Additional Context
        public string? RequestBody { get; set; }
        public string? ResponseBody { get; set; }
        public string? UserAgent { get; set; }
        public string? Referrer { get; set; }

        // Navigation properties
        public virtual Application Application { get; set; } = null!;
    }
} 